// 设置异步延迟间隔
import {ORDERING_GET_USER_INFO} from "@/assets/const/api";
import {HttpUtil} from "@/config/HttpUtil";
import store from '@/store/index.js';
export function readFile(file) {
    return new Promise((resolve) => {
        let reader = new FileReader();
        reader.readAsBinaryString(file);
        reader.onload = (e) => {
            resolve(e.target.result);
        };
    });
}

export function excelSerialToDateString(excelSerial) {
    // Excel日期的基准是1900年1月0日（即1899年12月31日）
    const baseDate = new Date(1899, 11, 30);
    // 将Excel日期序列号转换为JavaScript日期对象，并加上一天的偏差
    const jsDate = new Date(baseDate.getTime() + (excelSerial + 1) * 24 * 60 * 60 * 1000);

    const year = jsDate.getFullYear();
    const month = String(jsDate.getMonth() + 1).padStart(2, '0'); // getMonth() 返回值范围是0-11，需要加1
    const day = String(jsDate.getDate()).padStart(2, '0');

    return `${year}-${month}-${day}`;
}
export function getUserInfo() {
    return new Promise((resolve, reject) => {
        HttpUtil.get(ORDERING_GET_USER_INFO).then(res => {
            let info = res.data || {};
            store.commit('setUserInfo', info);
            resolve();
        }).catch((err) => {
            reject(err);
        });
    });
}
